<template>
  <div>
    <h2>{{ name }} - {{ age }}</h2>
    <button @click="btnClick">修改age</button>
  </div>
</template>

<script>
import { reactive, toRef, toRefs } from "vue";

export default {
  setup() {
    const info = reactive({ name: "why", age: 18 });
    // let { name, age } = toRefs(info);
    let { name } = info;
    let age = toRef(info, "age");

    const btnClick = () => {
      info.age++;
    };
    return { name, age, btnClick };
  },
};
</script>

<style scoped></style>
